package com.springboot.demo.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.springboot.demo.common.customValidator.ListNotHasNull;
import com.springboot.demo.entity.validate.TableBasicInfoGroup;
import com.springboot.demo.entity.validate.user.IdGroup;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.validator.constraints.Length;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.Valid;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
import java.util.Date;
import java.util.List;

/**
 * @author wubc683
 * @desc
 * @date 2021-07-26 15:13
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class Table {
    @ApiModelProperty(value = "报表id", required = true)
    @NotNull(message = "报表id不能为null",groups = IdGroup.class)
    private Long id;
    @ApiModelProperty("报表所有者id")
    private Long ownerId;
    @ApiModelProperty("报表所有者名称")
    private String ownerName;
    @ApiModelProperty(value = "报表创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createDate;
    @ApiModelProperty(value = "报表类型,1:指标卡，2：列表，3：折线图，4：柱状图，5：堆叠柱状图，6：条形图，7：饼图", required = true)
    @NotNull(message = "报表类型不能为null", groups = TableBasicInfoGroup.class)
    private Integer type;
    @ApiModelProperty(value = "报表标题,不超过16字符", required = true)
    @NotEmpty(message = "报表标题不能为空", groups = TableBasicInfoGroup.class)
    @Length(max = 16,message = "报表标题长度超限",groups = TableBasicInfoGroup.class)
    @Pattern(regexp = "^[\\u4E00-\\u9FA5a-zA-Z0-9_-]{1,16}$", message = "报表名格式错误")
    private String title;
    @ApiModelProperty(value = "数据表类型，1：用户表，2：设备表，3：场景表,4:历史数据表，5：历史报警表", required = true)
    @NotNull(message = "数据表不能为null")
    private Integer dataTableType;
    @ApiModelProperty(value = "维度,指标卡此参数无意义,传任意值", required = true)
    @NotNull(message = "报表维度不能为null")
    private Integer dimension;
    @ApiModelProperty(value = "对比维度,指标卡，饼图此参数无意义,传任意值", required = true)
    @NotNull(message = "报表对比值不能为null")
    private Integer compare;
    @ApiModelProperty(value = "是否能导出数据,指标卡没有，其他类型看用户是否勾选", required = false)
    private Boolean isExportAllowed;
    @ApiModelProperty(value = "数值,意义同维度", required = true)
    @NotNull(message = "报表数值不能为null")
    private Integer value;
    @ApiModelProperty(value = "值类型,1:计数,2:去重计数,3:平均值,4:最大值,5:最小值,6:求和,7:首值,8:尾值", required = true)
    @NotNull(message = "报表值类型不能为null")
    private Integer valueType;
    @ApiModelProperty(value = "报表过滤条件", required = true)
    @ListNotHasNull
    @Valid
    List<TableFilter> filters;
//    @ApiModelProperty("组件位置,即当组件被加入仪表盘时，组件在页面中的位置信息")
//    private ComponentPosition position;
}
